package main

import (
	"fmt"
	"math/rand"
	"time"
)

/*
@author: liujun
@file: 05.test.go
@time: 2022/11/11 17:32
*/

func main() {
	fmt.Println(staircase(5))
	gift()
}
//爬楼梯
func staircase(n int) int {
	if n == 1 || n ==2{
		return n
	}else {
		return  staircase(n-1) + staircase(n-2)
	}
}

//送礼物
func gift() {
	rand.Seed(time.Now().UnixNano())
	people := make([]string,5)
	people[0]="张三"
	people[1]="李四"
	people[2]="王五"
	people[3]="李大雷"
	people[4]="王小美"
	a := make([]string,5)
	a[0]="张三"
	a[1]="李四"
	a[2]="王五"
	a[3]="李大雷"
	a[4]="王小美"
	c := make([]string,0)
	for i:=0;i<len(a);i++ {
		d := a[0]
		a = a[1: ]
		num := rand.Intn(len(a))
		b := a[num]
		c = append(c, b)
		a = append(a[:num], a[num+1:]...)
		a = append(a,d)
		}
	num := len(people)-2
	if exist(people[num],a)||exist(people[num+1],a){
		if people[num] == a[0] || people[num+1] == a[1]{
			c = append(c, a[1],a[0])
		}else{
			c = append(c, a[0],a[1])
		}
	} else {
		c = append(c, a[0], a[1])
	}
	fmt.Println(c)
}

func exist(value string, list []string) bool {
	for _, v := range list{
		if v == value{
			return true
		}
	}
	return false
}